package com.hsgene.pay.domain;

/**
 * 回调的支付方式类型
 *
 * @author wxf
 * @date 2019/1/14 15:05
 **/
public enum CallBackPayType {

    /**
     * 回调支付方式
     */
    E(1, 0, "e融合支付"),

    ALIPAY(3, 1, "支付宝"),

    WECHAT(2, 2, "微信"),

    UNIONPAY(4, 3, "银联");

    /**
     * 回调的支付类型
     */
    private int subchannelType;

    /**
     * 数据库支付类型
     */
    private int dataBasePayChannel;

    /**
     * 描述
     */
    private String desc;

    CallBackPayType(int subchannelType, int dataBasePayChannel, String desc) {
        this.subchannelType = subchannelType;
        this.dataBasePayChannel = dataBasePayChannel;
        this.desc = desc;
    }

    public static int getCode(String code) {
        for (CallBackPayType payType : values()) {
            if (payType.subchannelType == Integer.parseInt(code)) {
                return payType.dataBasePayChannel;
            }
        }
        return E.dataBasePayChannel;
    }

    public int getSubchannelType() {
        return subchannelType;
    }

    public int getDataBasePayChannel() {
        return dataBasePayChannel;
    }

    public String getDesc() {
        return desc;
    }
}
